//
//  RBShopDetailVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/22.
//

#import "RBShopDetailVC.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RanTool.h"
#import "RBPager.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "RBNavigationBar.h"
#import "RBCollectionReusableView.h"
#import "RBGradientView.h"
#import <UIImage+YYAdd.h>
#import "RBSystemDetailGuessCell.h"
#import "UIButton+RBAdd.h"
#import "RBShopIntroVC.h"
#import "UIViewController+RBAdd.h"
#import "RBRefreshFooter.h"
#import "RBShopDetailResponse.h"
#import "RBShopDetailGoodsResponse.h"
#import "RBEmptyView.h"
#import "RBImageBannerView.h"
#import "RBGoodsDetailVC.h"

@interface RBShopDetailVC ()<UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate,UITextFieldDelegate>

@property(nonatomic, strong)UIView *bottomView;
@property(nonatomic, strong)UICollectionView *collectionView;
@property(nonatomic, strong)NSMutableArray *dataSource;
@property(nonatomic, strong)RBNavigationBar *navigationBar;
@property(nonatomic, strong)UIView *searchView;

@property(nonatomic, strong)UIView *filterView;
@property(nonatomic, strong)UIView *compositeFilterBtn;
@property(nonatomic, strong)UIView *salesFilterBtn;
@property(nonatomic, strong)UIView *priceFilterBtn;
@property (nonatomic, strong) UILabel *filterBtn;

@property(nonatomic, strong) RBShopDetailResponse *detailResponse;
@property(nonatomic, strong) RBShopDetailGoodsResponse *goodsResponse;

@property(nonatomic, assign) NSInteger filterIndex;
@property(nonatomic, assign) NSInteger filterState;
@property(nonatomic, copy) NSString *searchText;

@end

@implementation RBShopDetailVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
    [self getData];
}

#pragma mark - Private

- (void)setup
{
    self.statusBarStyle = UIStatusBarStyleLightContent;
    self.fd_prefersNavigationBarHidden = YES;
    self.view.backgroundColor = [RBThemeConfig bgGrayColor];
    self.collectionView.hidden = NO;
    self.navigationBar.hidden = NO;
    
    self.filterView.hidden = NO;
    self.filterIndex = 0;
    self.filterState = 1;
    [self setFilterBtn:self.compositeFilterBtn withTag:1];
    [self setFilterBtn:self.salesFilterBtn withTag:0];
    [self setFilterBtn:self.priceFilterBtn withTag:0];
}

- (void)fillData
{
    [self.dataSource removeAllObjects];
    UIView *topView = ({
        UIView *view = UIView.new;
        
        UIImageView *bgImgView = [RanTool imgViewWithMode:2 radius:0 imgName:@"shopDetailBg"];
        [view addSubview:bgImgView];
        [bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.mas_equalTo(0);
            make.height.mas_equalTo(Zoom(363));
        }];
        
        [view view_addView:({
            UIView *view = UIView.new;
            [view h_view_addView:[RanTool imgViewWithMode:2 radius:Zoom(3) imgName:self.detailResponse.data.logo] withHeight:Zoom(36) width:Zoom(36) top:0 bottom:0 left:0 right:0 centerY:0];
            [view h_view_addView:({
                UIView *view = UIView.new;
                
                UILabel *titleL = [RanTool labelWithFontSize:Zoom(15) weight:2 color:UIColor.whiteColor align:0 text:self.detailResponse.data.store_name];
                [view addSubview:titleL];
                [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.top.right.mas_equalTo(0);
                }];
                
                UILabel *desL = ({
                    UILabel *view = UILabel.new;
                    UIFont *font = [UIFont systemFontOfSize:Zoom(12)];
                    UIColor *color = UIColor.whiteColor;
                    view.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
                        CGFloat point = self.detailResponse.data.pingfen;
                        for (NSInteger i = 1; i <= 5; i++)
                        {
                            if (i != 1)
                            {
                                [maker addAttributeStringWithImage:[UIImage imageWithColor:UIColor.clearColor] imageSize:CGSizeMake(Zoom(1), Zoom(1)) maxFont:font];
                            }
                            NSString *imgName = @"";
                            if (point >= i)
                            {
                                imgName = @"shopStartSel";
                            }
                            else if(point > i - 1)
                            {
                                imgName = @"shopStartHalf";
                            }
                            else
                            {
                                imgName = @"shopStart";
                            }
                            [maker addAttributeStringWithImage:[UIImage imageNamed:imgName] imageSize:CGSizeMake(Zoom(9), Zoom(8)) maxFont:font];
                        }
                        [maker addAttributeStringWithFont:font color:color string:[NSString stringWithFormat:@"　%.1f", point]];
                    }];
                    view;
                });
                [view addSubview:desL];
                [desL mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.bottom.right.mas_equalTo(0);
                }];
                
                view;
            }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:Zoom(12) right:0 centerY:0];
            [view h_view_addView:({
                RBGradientView *view = [RBGradientView gradientViewWithColors:@[[UIColor colorWithHexString:@"#70A1FF"], [UIColor colorWithHexString:@"#2663D9"]] locations:nil vertical:NO];
                [view rbSetCornerRadius:Zoom(12)];
                [view view_addView:({
                    UILabel *view = UILabel.new;
                    [view rbAddTapGesWithTarget:self action:@selector(collectBtnTapped)];
                    view.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
                        UIFont *font = [UIFont systemFontOfSize:Zoom(12)];
                        [maker addAttributeStringWithImage:[UIImage imageNamed:self.detailResponse.data.is_shoucang? @"shopCollected": @"shopCollect"] imageSize:CGSizeMake(Zoom(12), Zoom(11)) maxFont:font];
                        [maker addAttributeStringWithFont:font color:UIColor.whiteColor string:(self.detailResponse.data.is_shoucang? @" 已收藏": @"  收藏")];
                    }];
                    view.textAlignment = NSTextAlignmentCenter;
                    view;
                }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:0 right:0 centerX:0];
                view;
            }) withHeight:Zoom(24) width:Zoom(70) top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(12) right:0 centerY:YES];
            view;
        }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:kRBStatusBarHeight + kRBNavigationBarHeight + Zoom(8) bottom:0 left:Zoom(15) right:Zoom(15) centerX:0];
        
        [view view_addView:({
            RBImageBannerView *view = RBImageBannerView.new;
            view.dataSource = self.detailResponse.data.picarr;
            [view rbSetCornerRadius:Zoom(10)];
            view;
        }) withHeight:Zoom(480) width:Zoom(345) top:Zoom(37) bottom:0 left:CGFLOAT_MIN right:CGFLOAT_MIN centerX:YES];
       
        view;
    });
    [self.dataSource addObject:({
        RBGroupModel *group = RBGroupModel.new;
        group.headerReuseIdentifier = NSStringFromClass(RBCollectionReusableView.class);
        group.headerView = topView;
        group.headerReferenceSize = CGSizeMake(kRBMainScreenWidth, topView.esSize.height);
        group;
    })];
    [self.dataSource addObject:({
        RBGroupModel *group = RBGroupModel.new;
        group.headerReuseIdentifier = NSStringFromClass(RBCollectionReusableView.class);
        group.headerView = self.filterView;
        group.headerReferenceSize = CGSizeMake(kRBMainScreenWidth, Zoom(60));
        group;
    })];
    [self.dataSource addObject:({
        RBGroupModel *group = RBGroupModel.new;
        group.sectionInset = UIEdgeInsetsMake(0, Zoom(15), Zoom(15), Zoom(15));
        group.minimumLineSpacing = Zoom(11);
        group.cellModels = ({
            NSMutableArray *arrayM = NSMutableArray.array;
            arrayM;
        });
        group;
    })];
    [self appendData];
}

- (void)appendData
{
    NSMutableArray *arrayM = ({
        RBGroupModel *group = self.dataSource.lastObject;
        (NSMutableArray *)group.cellModels;
    });
    for (NSInteger i = 0; i < self.goodsResponse.data.count; i++)
    {
        RBShopDetailGoodsModel *model = self.goodsResponse.data[i];
        [arrayM addObject:({
            RBCellModel *cellModel = RBCellModel.new;
            cellModel.reuseCellIdentifier = NSStringFromClass(RBSystemDetailGuessCell.class);
            cellModel.cellData = model;
            cellModel.cellSelectBlock = ^(NSIndexPath *indexPath) {
                RBGoodsDetailVC *vc = RBGoodsDetailVC.new;
                vc.id = model.id;
                [self.navigationController pushViewController:vc animated:YES];
            };
            cellModel;
        })];
    }
    RBGroupModel *lastGroup = self.dataSource.lastObject;
    if(!arrayM.count)
    {
        lastGroup.headerReuseIdentifier = NSStringFromClass(RBCollectionReusableView.class);
        lastGroup.headerView = RBEmptyView.new;
        lastGroup.headerReferenceSize = CGSizeMake(kRBMainScreenWidth, Zoom(140));

    }
    else
    {
        lastGroup.headerReuseIdentifier = nil;
        lastGroup.headerView = nil;
        lastGroup.headerReferenceSize = CGSizeZero;

    }
    [self.collectionView reloadData];
}

#pragma mark - Network

- (void)getData
{
    __weak typeof(self) weak_self = self;
    [self viewLoadDataWithParam:^(NSMutableDictionary *dicM) {
        dicM[@"store_id"] = self.id;
    } path:@"han_store_base" post:YES log:YES responseClass:RBShopDetailResponse.class desView:self.view showHud:YES showPlaceHolder:YES sucBlock:^(RBShopDetailResponse *response) {
        weak_self.detailResponse = response;
        [weak_self getFirstPageData];
    } failBlock:^(RBShopDetailResponse *response) {
        [weak_self.view showTip:response.message completion:nil];
    } reloadBlock:nil];
}

- (NSString *)listPageKey
{
    return @"page";
}
- (NSDictionary *)listParams
{
    NSMutableDictionary *dicM = NSMutableDictionary.dictionary;
    dicM[@"store_id"] = self.id;
    dicM[@"k"] = self.searchText;
    if(self.filterIndex == 3)
    {
//        dicM[@"type"] = @"huodong";
    }
    else
    {
        dicM[@"ord_name"] = @[@"id",@"sell_number",@"sell_price", @""][self.filterIndex];
        dicM[@"ord_val"] = self.filterState == 1? @"desc": @"asc";
    }
    return dicM;
}
- (NSString *)listRequestPath
{
    return @"han_store_list";
}
- (NSInteger)ListCurrentPage
{
    return self.goodsResponse.currentPage;
}
- (BOOL)listLog
{
    return YES;
}
- (BOOL)listPost
{
    return YES;
}
- (Class)listResponseClass
{
    return RBShopDetailGoodsResponse.class;
}
- (UIScrollView *)listView
{
    return self.collectionView;
}

- (void)getFirstPageData
{
    [self.view showProgressWithText:nil];
    __weak typeof(self) weak_self = self;
    [self listLoadFirstPageWithDesView:self.listView showPlaceHolder:YES sucBlock:^(id data) {
        [weak_self.view hideHud];
        weak_self.goodsResponse = data;
        [weak_self fillData];
    } failBlock:^(id data) {
        [weak_self.view hideHud];
    } reloadBlock:^{
        [weak_self getFirstPageData];
    }];
}

- (void)getNextPageData
{
    __weak typeof(self) weak_self = self;
    [self listLoadNextPageWithSucBlock:^(id data) {
        weak_self.goodsResponse = data;
        [weak_self appendData];
    } failBlock:^(id data) {
        
    }];
}

#pragma mark - Event

- (void)collectBtnTapped
{
    __weak typeof(self) weak_self = self;
    [self viewLoadDataWithParam:^(NSMutableDictionary *dicM) {
        dicM[@"goodsid"] = self.id;
        dicM[@"type"] = @"3";
    } path:@"han_store_do_collect" post:YES log:YES responseClass:RBResponse.class desView:self.view showHud:YES showPlaceHolder:YES sucBlock:^(RBResponse *response) {
        [weak_self getData];
    } failBlock:^(RBResponse *response) {
        [weak_self.view showTip:response.message completion:nil];
    } reloadBlock:nil];
}

- (void)compositeFilerBtnTapped
{
    NSInteger tag = self.compositeFilterBtn.tag + 1;
    if(tag > 2)
    {
        tag = 1;
    }
    [self setFilterBtn:self.compositeFilterBtn withTag:tag];
    [self setFilterBtn:self.salesFilterBtn withTag:0];
    [self setFilterBtn:self.priceFilterBtn withTag:0];
    self.filterIndex = 0;
    self.filterState = tag;
    [self getFirstPageData];
}

- (void)salesFilerBtnTapped
{
    NSInteger tag = self.salesFilterBtn.tag + 1;
    if(tag > 2)
    {
        tag = 1;
    }
    [self setFilterBtn:self.salesFilterBtn withTag:tag];
    [self setFilterBtn:self.compositeFilterBtn withTag:0];
    [self setFilterBtn:self.priceFilterBtn withTag:0];
    self.filterIndex = 1;
    self.filterState = tag;
    [self getFirstPageData];
}

- (void)priceFilerBtnTapped
{
    NSInteger tag = self.priceFilterBtn.tag + 1;
    if(tag > 2)
    {
        tag = 1;
    }
    [self setFilterBtn:self.priceFilterBtn withTag:tag];
    [self setFilterBtn:self.compositeFilterBtn withTag:0];
    [self setFilterBtn:self.salesFilterBtn withTag:0];
    self.filterIndex = 2;
    self.filterState = tag;
    [self getFirstPageData];
}

- (void)filterBtnTapped
{
    if (self.filterIndex == 3) {
        return;
    }
    [self setFilterBtn:self.compositeFilterBtn withTag:0];
    [self setFilterBtn:self.salesFilterBtn withTag:0];
    [self setFilterBtn:self.priceFilterBtn withTag:0];
    
    self.filterBtn.textColor = [UIColor colorWithHexString:@"#3974EC"];
    self.filterIndex = 3;
    self.filterState = 1;
    [self getFirstPageData];
}

- (void)allGoodsBtnTapped
{
    
}

- (void)contactServiceBtnTapped
{
    [RanTool telWithNumber:self.detailResponse.data.hot_phone];
}

- (void)shopIntroBtnTapped
{
    RBShopIntroVC *vc = RBShopIntroVC.new;
    vc.id = self.id;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - UIScrollViewDelegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat duration = Zoom(100);
    CGFloat factor = MIN(1, scrollView.contentOffset.y/duration);
    self.navigationBar.backgroundAlpha = factor;
    UIButton *backBtn = [self.navigationBar.naviBar getBackBtn];
    [backBtn rbSetImage:[UIImage imageNamed:factor > 0.5? @"backBlack": @"backArror"]];
    self.searchView.backgroundColor = factor > 0.5? [RBThemeConfig bgGrayColor]: UIColor.whiteColor;
    self.statusBarStyle = factor > 0.5? UIStatusBarStyleDefault:UIStatusBarStyleLightContent;
}

#pragma mark - UICollectionViewDataSource & UICollectionViewDelegate

kRBCollectionViewDataSourceAndDelegateAuto(self.dataSource);

#pragma mark - UITextFieldDelegate

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    self.searchText = textField.text;
    [self getFirstPageData];
    return YES;
}

#pragma mark - Setter

- (void)setFilterBtn: (UIView *)filterBtn withTag: (NSInteger)tag
{
    self.filterBtn.textColor = [RBThemeConfig textBlackColor];
    filterBtn.tag = tag;
    UILabel *textL = (UILabel *)[filterBtn viewWithTag:222];
    UIImageView *upImgView = (UIImageView *)[filterBtn viewWithTag:333];
    UIImageView *dowImgView = (UIImageView *)[filterBtn viewWithTag:444];
    if (tag == 0)
    {
        upImgView.image = [UIImage imageNamed:@"shopFilterUp"];
        dowImgView.image = [UIImage imageNamed:@"shopFilterDown"];
        
        textL.textColor = [RBThemeConfig textBlackColor];
    }
    else if (tag == 2)
    {
        upImgView.image = [UIImage imageNamed:@"shopFilterUpSel"];
        dowImgView.image = [UIImage imageNamed:@"shopFilterDown"];
        textL.textColor = [UIColor colorWithHexString:@"#3974EC"];
    }
    else if (tag == 1)
    {
        upImgView.image = [UIImage imageNamed:@"shopFilterUp"];
        dowImgView.image = [UIImage imageNamed:@"shopFilterDownSel"];
        textL.textColor = [UIColor colorWithHexString:@"#3974EC"];
    }
        
}

#pragma mark - Getter

- (UIView *)bottomView
{
    if (!_bottomView)
    {
        self.bottomView = ({
            CGFloat toolBarH = Zoom(55);
            UIView *view = UIView.new;
            view.backgroundColor = UIColor.whiteColor;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.left.right.mas_equalTo(0);
                make.height.mas_equalTo(toolBarH + kRBSafeBottomHeight);
            }];
            
            UIView *toolView = UIView.new;
            [view addSubview:toolView];
            [toolView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.top.mas_equalTo(0);
                make.height.mas_equalTo(toolBarH);
            }];
            
            CGFloat itemW = kRBMainScreenWidth/2 - 1;
//            [toolView h_view_addView:[self botomItemWithTitle:@"全部商品" img:@"shopAllGoods" sel:@selector(allGoodsBtnTapped)] withHeight:CGFLOAT_MIN width:itemW top:0 bottom:0 left:0 right:0 centerY:0];
            [toolView h_view_addView:[self bottomSepView] withHeight:Zoom(17) width:1 top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:0 right:0 centerY:YES];
            [toolView h_view_addView:[self botomItemWithTitle:@"联系客服" img:@"shopContact" sel:@selector(contactServiceBtnTapped)] withHeight:CGFLOAT_MIN width:itemW top:0 bottom:0 left:0 right:0 centerY:0];
            [toolView h_view_addView:[self bottomSepView] withHeight:Zoom(17) width:1 top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:0 right:0 centerY:YES];
            [toolView h_view_addView:[self botomItemWithTitle:@"店铺介绍" img:@"shopIntro" sel:@selector(shopIntroBtnTapped)] withHeight:CGFLOAT_MIN width:itemW top:0 bottom:0 left:0 right:0 centerY:0];
            
            [view view_addView:({
                UIView *view = UIView.new;
                view.backgroundColor = [RBThemeConfig bgGrayColor];
                view;
            }) withHeight:1 width:CGFLOAT_MIN top:0 bottom:CGFLOAT_MIN left:0 right:0 centerX:0];
            
            view;
        });
    }
    return _bottomView;
}

- (UILabel *)botomItemWithTitle: (NSString *)title img: (NSString *)img sel: (SEL)sel
{
    UILabel *view = UILabel.new;
    UIFont *font = [UIFont systemFontOfSize:Zoom(14)];
    UIColor *color = [RBThemeConfig textBlackColor];
    view.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
        [maker addAttributeStringWithImage:[UIImage imageNamed:img] imageSize:CGSizeMake(Zoom(21), Zoom(21)) maxFont:font];
        [maker addAttributeStringWithFont:font color:color string:[@" " stringByAppendingString:title]];
    }];
    view.textAlignment = NSTextAlignmentCenter;
    [view rbAddTapGesWithTarget:self action:sel];
    return view;
}

- (UIView *)bottomSepView
{
    UIView *view = UIView.new;
    view.backgroundColor = [UIColor colorWithHexString:@"#BFBFBF"];
    return view;
}

- (UICollectionView *)collectionView
{
    if (!_collectionView)
    {
        self.collectionView = ({
            UICollectionViewFlowLayout *layout = UICollectionViewFlowLayout.new;
            layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize;
            UICollectionView *view = [UICollectionView.alloc initWithFrame:CGRectZero collectionViewLayout:layout];
            view.showsVerticalScrollIndicator = NO;
            view.showsHorizontalScrollIndicator = NO;
            view.dataSource = self;
            view.delegate = self;
            view.backgroundColor = UIColor.clearColor;
            view.mj_footer = [RBRefreshFooter footerWithRefreshingTarget:self refreshingAction:@selector(getNextPageData)];
            kRBIgnoreScrollViewInsetsAdjust(view);
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(0);
                make.right.mas_equalTo(0);
                make.bottom.mas_equalTo(self.bottomView.mas_top);;
                make.top.mas_equalTo(0);
            }];
            view;
        });
    }
    return _collectionView;
}

- (NSMutableArray *)dataSource
{
    if (!_dataSource)
    {
        self.dataSource = ({
            NSMutableArray *arrayM = NSMutableArray.array;
            arrayM;
        });
    }
    return _dataSource;
}


- (RBNavigationBar *)navigationBar
{
    if (!_navigationBar)
    {
        self.navigationBar = ({
            RBNavigationBar *view = RBNavigationBar.new;
            view.needGradientView = NO;
            view.bgColor = UIColor.whiteColor;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.top.mas_equalTo(0);
                make.height.mas_equalTo(kRBStatusBarHeight + kRBNavigationBarHeight);
            }];
            
            [view.naviBar addBackBtn];
            [view.naviBar h_view_addView:({
                UIView *view = UIView.new;
                self.searchView = view;
                view.backgroundColor = UIColor.whiteColor;
                [view rbSetCornerRadius:Zoom(15)];
                
                [view h_view_addView:[RanTool imgViewWithMode:1 radius:0 imgName:@"homeSearchIcon"] withHeight:Zoom(16) width:Zoom(14) top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(11) right:0 centerY:YES];
                [view h_view_addView:({
                    UITextField *view = UITextField.new;
                    view.delegate = self;
                    view.returnKeyType = UIReturnKeySearch;
                    view.font = [UIFont systemFontOfSize:Zoom(12)];
                    view.placeholder = @"请输入商品名称";
                    view.textColor = [RBThemeConfig textBlackColor];
                    view;
                }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:Zoom(8) right:Zoom(15) centerY:0];
                
                view;
            }) withHeight:Zoom(30) width:CGFLOAT_MIN top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(38) right:Zoom(30) centerY:YES];
            
            view;
        });
    }
    return _navigationBar;
}

- (UIView *)filterView
{
    if (!_filterView)
    {
        self.filterView = ({
            UIView *view = UIView.new;
            
            UIStackView *stackView = UIStackView.new;
            [view addSubview:stackView];
            [stackView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.bottom.mas_equalTo(0);
                make.left.mas_equalTo(Zoom(24));
                make.right.mas_equalTo(-Zoom(24));
            }];
            stackView.distribution = UIStackViewDistributionEqualSpacing;
            
            self.compositeFilterBtn = [self filterBtnWithTitle:@"综合"];
            [self.compositeFilterBtn rbAddTapGesWithTarget:self action:@selector(compositeFilerBtnTapped)];
            [stackView addArrangedSubview:self.compositeFilterBtn];
            
            self.salesFilterBtn = [self filterBtnWithTitle:@"销量"];
            [self.salesFilterBtn rbAddTapGesWithTarget:self action:@selector(salesFilerBtnTapped)];
            [stackView addArrangedSubview:self.salesFilterBtn];
            
            self.priceFilterBtn = [self filterBtnWithTitle:@"价格"];
            [self.priceFilterBtn rbAddTapGesWithTarget:self action:@selector(priceFilerBtnTapped)];
            [stackView addArrangedSubview:self.priceFilterBtn];
            
            UILabel *filterBtn = [RanTool labelWithFontSize:Zoom(13) weight:0 color:[RBThemeConfig textBlackColor] align:0 text:@"筛选"];
            [filterBtn rbAddTapGesWithTarget:self action:@selector(filterBtnTapped)];
            [stackView addArrangedSubview:filterBtn];
            self.filterBtn = filterBtn;
            
            view;
        });
    }
    return _filterView;
}

- (UIView *)filterBtnWithTitle: (NSString *)title
{
    UIView *view = UIView.new;
    [view h_view_addView:({
        UILabel *view = [RanTool labelWithFontSize:Zoom(13) weight:0 color:[RBThemeConfig textBlackColor] align:0 text:title];
        view.tag = 222;
        view;
    }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:0 right:0 centerY:0];
    [view h_view_addView:({
        UIView *view = UIView.new;
        [view view_addView:({
            UIImageView *view = [RanTool imgViewWithMode:0 radius:0 imgName:@"shopFilterUp"];
            view.tag = 333;
            view;
        }) withHeight:Zoom(5) width:Zoom(7) top:0 bottom:0 left:0 right:0 centerX:0];
        [view view_addView:({
            UIImageView *view = [RanTool imgViewWithMode:0 radius:0 imgName:@"shopFilterDown"];
            view.tag = 444;
            view;
        }) withHeight:Zoom(5) width:Zoom(7) top:Zoom(2) bottom:0 left:0 right:0 centerX:0];
        view;
    }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(6) right:0 centerY:YES];
    return view;
}

@end
